﻿Imports System.Data
Imports VSModel
Imports Cls_Common
Partial Class FrontEnd_Control_IndexContent
    Inherits System.Web.UI.UserControl

    Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            LoadContent()
        End If
    End Sub
    Protected Sub LoadContent()
        Dim lstNodeL As New DataSet
        lstNodeL.ReadXml(MapPath("../../xml/ContentLeft.xml"))
        With rptContentLeft
            .DataSource = lstNodeL.Tables("Node")
            .DataBind()
        End With
        Using _data As New VSEntities
            Dim p = (From q In _data.Menus Where q.TitlePage = "nganh-nghe-kinh-doanh-co-dieu-kien" Select q).FirstOrDefault
            If Not p Is Nothing Then
                Dim k = (From q In _data.Menus Where q.ParentId = p.MenuId Select q).Take(8).ToList
                With rptContentRight
                    .DataSource = k
                    .DataBind()
                End With
            End If

        End Using
        'Dim lstNodeR As New DataSet
        'lstNodeR.ReadXml(MapPath("../../xml/ContentRight.xml"))
        'With rptContentRight
        '    .DataSource = lstNodeR
        '    .DataBind()
        'End With
    End Sub

    Protected Sub rptContentLeft_ItemDataBound(sender As Object, e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles rptContentLeft.ItemDataBound
        Dim hplTitle As HyperLink = CType(e.Item.FindControl("hplTitle"), HyperLink)
        hplTitle.NavigateUrl = MainDomain & e.Item.DataItem("URL").ToString
        hplTitle.Text = e.Item.DataItem("Title")
    End Sub

    Protected Sub rptContentRight_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles rptContentRight.ItemDataBound
        Dim row As Menu = CType(e.Item.DataItem, Menu)
        Dim hplTitle As HyperLink = CType(e.Item.FindControl("hplTitle"), HyperLink)
        hplTitle.NavigateUrl = MainDomain & "nganh-nghe-kinh-doanh-co-dieu-kien.html?Id=" & row.MenuId
        hplTitle.Text = row.Title
    End Sub
End Class
